import 'package:flutter/material.dart';
import 'package:flutter_lqy_demo/common/style/gsy_style.dart';
import 'package:flutter_lqy_demo/common/utils/navigator_utils.dart';
import 'package:flutter_lqy_demo/widget/diff_scale_text.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 欢迎页

class WelcomePage extends StatefulWidget {
  static const String sName = "/";

  const WelcomePage({super.key});
  @override
  WelcomePageState createState() => WelcomePageState();
}

class WelcomePageState extends State<WelcomePage> {
  bool hadInit = false;
  bool isLogin = true;
  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    if (hadInit) {
      return;
    }
    hadInit = true;

    //模拟网页加载延迟
    Future.delayed(const Duration(milliseconds: 1000), () {
      //是否登录
      if (isLogin) {
        NavigatorUtils.goHome(context);
      } else {
        NavigatorUtils.goLogin(context);
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      child: Container(
        color: GSYColors.white,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Center(
              child: Image(image: AssetImage("assets/images/icon_logo.png")),
            ),
            Text(
              "LMQ",
              style: TextStyle(
                color: GSYColors.primaryDarkValue,
                fontSize: 18.sp,
                fontWeight: FontWeight.bold,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
